//compositionAPI插件
import VueCompositionAPI from '@vue/composition-api';
//axios请求插件
import axios from 'axios';

//转换编译js代码
import "babel-polyfill";
//echarts数据可视化插件
import * as echarts from 'echarts';
import ElementUI from 'element-ui';

// element-ui组件库, 改变穿梭框大小，在\vue-admin-master\node_modules_element-ui@2.4.6@element-ui\lib\theme-chalk\index.css
// 将.el-transfer-panel 这个类=> width从200px 改成width:500px; .el-transfer-panel__body中 height： 246px 改为 446px
//.el-transfer-panel__list.is-filterable height: 194px改为 height: 394px;

import 'element-ui/lib/theme-chalk/index.css';
// * 这里的自适应需要自行修改依赖文件以到达自适应效果 node_modules ->
// lib-flexible -> flexible.js 将 refreshRem的函数里的 width = 540 * dpr 改为 width = width * dpr 即可;
import "lib-flexible";
import "lib-flexible/flexible";
//顶部页面加载条
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
//qs - axios参数序列化插件
import qs from 'qs';
import Vue from 'vue';
//重置样式和字体
import '../static/css/main.css';
import '../static/font/font.css';
import App from './App';
//全局封装方法
import base from "./base";
//api原型全局挂载 - 线上接口地址
import apiUrl from './components/common/Global.vue';
//路由
import router from './router';
//导出表格
import JsonExcel from 'vue-json-excel'

//启动项目生产消息
Vue.config.productionTip = false;

Vue.use(ElementUI);

Vue.prototype.$echarts = echarts;


NProgress.configure({
  easing: 'ease',
  speed: 500,
  showSpinner: false,
  trickleSpeed: 200,
  minimum: 0.3
});

axios.defaults.withCredentials = true;
Vue.prototype.$axios = axios;

Vue.prototype.qs = qs;

Vue.use(VueCompositionAPI);

Vue.use(base);
Vue.component('downloadExcel', JsonExcel)
Vue.prototype.apiUrl = apiUrl.apiUrl;

// 引入mathjs
import * as math from 'mathjs';
Vue.prototype.$math = math;
// import {filterPrice} from "./units/time"
// filterPrice()
//
// Vue.filter('SumFromatAll', function( amount, serviceFee, delayShareAmount,overdueAmount, that){
//   console.log(amount, serviceFee, delayShareAmount,overdueAmount)
//   let stagePayMoeny = '';
//   if (amount != null && serviceFee  != null&&delayShareAmount!==null && overdueAmount!=null) {
//     stagePayMoeny = that.$math.add(that.$math.bignumber(amount), that.$math.bignumber(serviceFee),that.$math.bignumber(delayShareAmount),that.$math.bignumber(overdueAmount))
//
//   }
//
//   return stagePayMoeny;
//
//
// })
//路由监听
router.beforeEach((to, from, next) => {
  NProgress.start();
  let userName = localStorage.getItem("userName");
  //
  if (userName) {
    next()
  } else {
    if (to.path === "/") {
      next()
    } else {
      // alert("没有访问权限或登陆已过期，请重新登陆");
      next('/')
    }
  }
});
//路由跳转结束
router.afterEach(() => {
  NProgress.done()
});
//挂载
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
});
